<include file="Public:header" /> 
<link href="__APP__/statics/css/picview.css" rel="stylesheet" type="text/css"  charset="utf-8"/>

<script type="text/javascript" src="__APP__/statics/jquery.1.4.2.js"></script>
<script type="text/javascript" src="__APP__/statics/js/picview.js"></script>

<input type="text" id="good_id" style="display:none" value="{$goods.goods_id}">
<input type="text" id="choose_id" style="display:none" value="{$product_id}">
<div class="goods">
<!--左边-->
     <block name="content3"></block>
	<!--preview左边 end-->
<!--右边-->
	<div class="sgood">
	   <div class="title">{$goods.goods_name}<br>
		  <font size="2" color="red">{$goods.s_intro}</font>
	  </div>
	  <div class="price">
	     <li>市场价：<strike>{$goods.market_price}</strike></li>
		 <li>销售价：<font size="4" color="red"><span id="n_price">{$goods.price}</span></font></li>
		 <li>品&nbsp;&nbsp;&nbsp;牌：雅诗兰黛</li>
		 <li>单&nbsp;&nbsp;&nbsp;位：{$goods.unit}</li>
		 <li>重&nbsp;&nbsp;&nbsp;量：{$goods.weight} g</li>
	  </div>
 
     <div class="prop">
<!--规格1-->
       <div class="poo">
	   <span style="margin-top:6px;">{$prop1_n}</span>
	    <span class="catt">
<volist name="prop1" id="prop1">
          <a  onclick="changeAtt(this)" href="javascript:;">{$prop1}<input style="display:none" name="guige1" id="guige1" type="radio" value="{$prop1}"/></a>
</volist>
       </span>
	   </div>
	   <div class="clear"></div>
<!--规格2-->
      <div class="poo">
	   <span style="margin-top:6px;">{$prop2_n}</span>
	    <span class="catt">
<volist name="prop2" id="prop2">
          <a  onclick="changeAtt(this)" href="javascript:;">{$prop2}<input style="display:none" name="guige2" id="guige2" type="radio" value="{$prop2}"/></a>
</volist>
       </span>
	  </div>
	  <div class="clear"></div>
	  
	  <!--prop结束-->
	  <div class="buy_zone">
	    <div id="get_prop" style="margin-left:20px;"><font color="red"><span id="a_prop"></span></font></div>
		<div class="goods_num">
			购买数量：
			<input id="min" name="" type="button"  style="height:20px;width:15px;" value="-" />
			<input id="text_box" name="" type="text" style="width:15px;" value="1" readonly/>
			<input id="add" name="" type="button" style="height:20px;width:15px;" value="+" />
			(库存:<span id="store">有货</span>)
		</div>
<if condition="$goods.store gt 0">
		<div class="buy" id="buy">
			<a onclick="buy()" href="javascript:;" ><img src="__APP__/statics/btn-buy.gif" border="0"/></a>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<a onclick="buy()" href="javascript:;"><img src="__APP__/statics/btn-fastbuy.gif"  border="0"/></a>
		</div>
<else/>	
		<div class="buy" id="buy">
			很遗憾，没货啦！
		</div>
</if>
      </div>
	   <!--buy_zone结束-->
	</div>
	<!--sgood结束-->
</div>
<!--goods结束-->
<div class="clear">
{$goods.intro}
	
	



<div class="clear">
<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>
<script type="text/javascript" src="__APP__/statics/js/re_num.js"></script>
<script type="text/javascript">
	//规格选择
	function changeAtt(t) {
     t.lastChild.checked='checked';
     for (var i = 0; i<t.parentNode.childNodes.length;i++) {
            if (t.parentNode.childNodes[i].className == 'cattsel') {
                   t.parentNode.childNodes[i].className = '';
            }
      }
          t.className = "cattsel";
          changePrice();
     }

     function changePrice(){
	    var q1=$("input[name='guige1']").val();
        var p1=$("input[name='guige1']:checked").val();
		var q2=$("input[name='guige2']").val();
		var p2=$("input[name='guige2']:checked").val();
		var id=$("#good_id").val();
		if(p1==undefined){
		     $("#a_prop").html("已选择："+p2);
	     }else if(p2==undefined){
		     $("#a_prop").html("已选择："+p1);
		}else{
		     $("#a_prop").html("已选择："+p1+","+p2);
		}

      if(q1!=undefined&&q2!=undefined){
	     if(p1!=undefined&&p2!=undefined){
					$.ajax({
					type:"POST",
					url:"__URL__/get_price",
					dataType:"json",
					data:{id:id,prop1:p1,prop2:p2},
					success:function(data){
								if(data.store>='1'){
										$("#n_price").html(data.price);
										$("#buy").html("<a onclick='buy()' href='javascript:;'><img src='__APP__/statics/btn-buy.gif' border='0'/></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick='buy()' href='javascript:;'><img src='__APP__/statics/btn-fastbuy.gif'  border='0'/></a>");
										$("#store").html(data.store);
										$("#choose_id").val(data.choose_id);
								}else{
										$("#buy").html("<font color='red'><b>很遗憾，此组合无货！</b></font>");
										$("#store").html("无货");
							    }
					}
					})
				}
		 }
		 //判断是否有值结束
		 if((q1==undefined&&q2!=undefined&&p2!=undefined)||(q1!=undefined&&q2==undefined&&p1!=undefined)){
				$.ajax({
					type:"POST",
					url:"__URL__/get_price",
					dataType:"json",
					data:{id:id,prop1:p1,prop2:p2},
					success:function(data){
								if(data.store>='1'){
										$("#n_price").html(data.price);
										$("#buy").html("<a onclick='buy()' href='javascript:;'><img src='__APP__/statics/btn-buy.gif' border='0'/></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick='buy()' href='javascript:;'><img src='__APP__/statics/btn-fastbuy.gif'  border='0'/></a>");
										$("#store").html(data.store);
										$("#choose_id").val(data.choose_id);
								}else{
										$("#buy").html("<font color='red'><b>很遗憾，此组合无货！</b></font>");
										$("#store").html("无货");
							    }
					}
					})
		 }

     }

	 function buy(){
	    var q1=$("input[name='guige1']").val();
        var p1=$("input[name='guige1']:checked").val();
		var q2=$("input[name='guige2']").val();
		var p2=$("input[name='guige2']:checked").val();
		if((q1!=undefined&&p1==undefined)||(q2!=undefined&&p2==undefined)){
	           jError("<strong>请选择规格！</strong>",{
			   VerticalPosition : 'center',
			   HorizontalPosition : 'center'
		       });
		 }else{
		     addCart();
		}
	}

	function addCart(){
	     var product_id=$("#choose_id").val();
		 var buy_num=$("#text_box").val();
		  $.ajax({
		    type:"POST",
					url:"__GROUP__/Cart/add",
					dataType:"html",
					data:{id:product_id,num:buy_num},
					success:function(data){
					                jSuccess("<strong>加入购物车成功！</strong>",{
			                        VerticalPosition : 'center',
			                        HorizontalPosition : 'center'
		                            });
					              }

		 })
		//jNotify("注意：请完善你的<strong>个人资料！</strong>");
	}
</script>
<include file="Public:footer" /> 
